package com.test.practice.collection;

/**
 * @Description: =======================
 * @Author: Jovi
 * =======================
 * @Date: Created in 2023-02-08
 * =======================
 * @Version: 1.1.2.0
 */
public class Student implements Comparable<Student> {
    private String name;
    private String sex;

    /**
     * 获取 name
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置 name
     *
     * @param name name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取 sex
     *
     * @return sex
     */
    public String getSex() {
        return sex;
    }

    /**
     * 设置 sex
     *
     * @param sex sex
     */
    public void setSex(String sex) {
        this.sex = sex;
    }

    public Student(String name, String sex) {
        this.name = name;
        this.sex = sex;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return "name:" + name + "sex:" + sex;
    }

    /**
     * 按照姓名排序
     *
     * @param o
     * @return
     */
    @Override
    public int compareTo(Student o) {
        if (o instanceof Student) {
            int i = this.name.compareTo(o.name);
            if (i != 0) {
                return i;
            }
            return this.sex.compareTo(o.sex);
        }
        return 0;
    }
}